<template>
	<view>
		<view class="pub-box">
				<view class="pub-box-bd">
					<view class="weui-cell weui-cell_input">
						<view class="weui-cell__hd">
							<view class="weui-label">
								就诊医院
							</view>
						</view>
						<view class="weui-cell__bd">
							
						</view>
						<view class="weui-cell__ft weui-cell__ft_in-access">
							<picker 
								@change="onHisChange" 
								:value="curHospital.id" 
								:range="hospitals"
								range-key ="name"
							>
								<input 
									type="text"
									:disabled="true"
									placeholder="请选择要就诊的医院"
									:value="curHospital.name"
									placeholder-class="vp-placeholder"
								/>
							</picker>
						</view>
					</view>
					<view class="weui-cell weui-cell_input">
						<view class="weui-cell__hd">
							<view class="weui-label">
								就诊时间
							</view>
						</view>
						<view class="weui-cell__bd">
							
						</view>
						<view class="weui-cell__ft weui-cell__ft_in-access">
							<view>
								<dtPicker
									@dtPickerChanged="onStartTimeChanged"
									:timestamp = "formData.starttime"
									placeholder="请选择就诊时间"
								></dtPicker>
							</view>
						</view>
					</view>
					<view class="weui-cell weui-cell_input" @click="onClientChange">
						<view class="weui-cell__hd">
							<view class="weui-label">
								就诊人
							</view>
						</view>
						<view class="weui-cell__bd">
							
						</view>
						<view class="weui-cell__ft weui-cell__ft_in-access">
							<view>
								<input
								:value="formData.client.name"
								placeholder="请选择就诊人"
								placeholder-class="vp-placeholder"
								disabled
								/>
							</view>
						</view>
					</view>
					
					<view class="weui-cell">
						<view class="weui-cell__hd">
							<view class="weui-label">接送地址</view>
						</view>
						<view class="weui-cell__bd"></view>
						<view class="weui-cell__ft">
							<view>
								<input 
									v-model="formData.receiveAddress"
									placeholder="请填写就诊人所在地址"
									placeholder-class="vp-placeholder"
								/>
							</view>
						</view>
					</view>
					
					<view class="weui-cell">
						<view class="weui-cell__hd">
							<view class="weui-label">联系电话</view>
						</view>
						<view class="weui-cell__bd"></view>
						<view class="weui-cell__ft">
							<view>
								<input
									v-model="formData.tel"
									placeholder="请填写联系电话"
									placeholder-class="vp-placeholder"
								/>
							</view>
						</view>
					</view>
				</view>
			</view>
			
			<view class="pub-box">
			    <view class="pub-box-tt">服务需求</view>
			    <view class="pub-box-bd">
			        <view class="weui-cell weui-cell_input">
			            <view class="weui-cell__bd">
			                <textarea 
								name="demand" 
								auto-height 
								placeholder="请简单描述您要就诊的科室..."
			                    placeholder-class="vp-placeholder" 
								style="min-height: 150rpx"
								v-model="formData.demand" 
							/>
			            </view>
			        </view>
			    </view>
			</view>
			
		<SubmitOrder
			:service="service"
			:curHospital ="curHospital"
			:formData = "formData"
		/>
			
	</view>
</template>

<script>
	import SubmitOrder from './submit.vue'
	export default {
		components:{SubmitOrder},
		props:["formData","price"],
		props:["service","hospitals","curHospital"],
		data() {
			return {
				//订单数据
				formData:{
					//就诊时间
					starttime:'',
					//就诊人
					client:{
						age:'',
						mobile:'',
						name:'',
						sex:''
					},
					//接送地址
					receiveAddress:'',
					//联系电话
					tel:'',
					//服务需求
					demand:''
				}
			}
		},
		methods: {
			//改变医院的数据
			onHisChange(e){
				this.$emit("update:curHospital",this.hospitals[e.detail.value])
			},
			//修改日期后的回调
			onStartTimeChanged(e){
				console.log(e)
				this.formData.starttime = e.detail.value
			},
			//选择就诊人
			onClientChange(){
				uni.navigateTo({
					url:'../clients/index?act=select'
				})
				//创建监听全局自定义事件，获取就诊人name
				uni.$on("clientName",({client})=>{
					this.formData.client ={ age:client.age,mobile:client.mobile,name:client.name,sex:client.sex}
				})
				
			},
			//是否同意用户协议
			ondealChange(){
				this.isDeal = !this.isDeal
			}
		}
	}
</script>

<style>

</style>
